package cn.jiangjiesheng.bootstrap.commons.config;

import com.fasterxml.jackson.databind.PropertyNamingStrategy;

/**
 * Created by dev@jiangjiesheng.cn on 2022/3/18  <br/>
 *
 * @author dev@jiangjiesheng.cn
 */
public class MyJacksonPropertyNamingStrategy extends PropertyNamingStrategy.PropertyNamingStrategyBase {

    public MyJacksonPropertyNamingStrategy() {
        super();
    }

    @Override
    public String translate(String input) {
        if (input != null && input.length() != 0) {
            char c = input.charAt(0);
            char uc = Character.toLowerCase(c);
            if (c == uc) {
                return input;
            } else {
                StringBuilder sb = new StringBuilder(input);
                sb.setCharAt(0, uc);
                return sb.toString();
            }
        } else {
            return input;
        }
    }
}
